#include "stdafx.h"
#include "StateManager.h"
#include "Marco.h"

StateManager* StateManager::instance = NULL;
StateManager::StateManager()
{
	/*instance = new StateManager();*/
	for (int i = 0; i < 10; i++)
		listState[i] = NULL;
	currentState = NULL;
}


StateManager::~StateManager()
{
	//Delete(instance);
	for (int i = 0; i < 10; i++)
		Delete(listState[i]);
}

StateManager* StateManager::GetInstance()
{
	if (!instance)
		instance = new StateManager();
	return instance;
}

void StateManager::SwitchState(State* newState, bool isReleaseOldState)
{
	if (isReleaseOldState)
	{
		Delete(currentState);
	}
	currentState = newState;
}

void StateManager::AddState(State* newState)
{
	if (count == 10)
		return;
	listState[count] = newState;
	count++;
}

State* StateManager::GetState(int index)
{
	return listState[index];
}